package it.stasbranger.myproject.service;

import it.stasbranger.myproject.domain.Requests;
import it.stasbranger.myproject.domain.Suppliers;
import it.stasbranger.myproject.domain.SuppliersHasRequests;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/MyProject-security-context.xml",
		"file:./resources/MyProject-service-context.xml",
		"file:./resources/MyProject-dao-context.xml",
		"file:./resources/MyProject-web-context.xml" })
@Transactional
public class SuppliersHasRequestsServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected SuppliersHasRequestsService service;

	/**
	 * Instantiates a new SuppliersHasRequestsServiceTest.
	 *
	 */
	public SuppliersHasRequestsServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing SuppliersHasRequests entity
	 * 
	 */
	@Test
	public void deleteSuppliersHasRequests() {
		// TODO: JUnit - Populate test inputs for operation: deleteSuppliersHasRequests 
		SuppliersHasRequests suppliershasrequests = new it.stasbranger.myproject.domain.SuppliersHasRequests();
		service.deleteSuppliersHasRequests(suppliershasrequests);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Suppliers entity
	 * 
	 */
	@Test
	public void saveSuppliersHasRequestsSuppliers() {
		// TODO: JUnit - Populate test inputs for operation: saveSuppliersHasRequestsSuppliers 
		Integer suppliersIdsuppliers = 0;
		Integer requestsIdrequests = 0;
		Suppliers related_suppliers = new it.stasbranger.myproject.domain.Suppliers();
		SuppliersHasRequests response = null;
		response = service.saveSuppliersHasRequestsSuppliers(suppliersIdsuppliers, requestsIdrequests, related_suppliers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveSuppliersHasRequestsSuppliers
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findSuppliersHasRequestsByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findSuppliersHasRequestsByPrimaryKey 
		Integer suppliersIdsuppliers_1 = 0;
		Integer requestsIdrequests_1 = 0;
		SuppliersHasRequests response = null;
		response = service.findSuppliersHasRequestsByPrimaryKey(suppliersIdsuppliers_1, requestsIdrequests_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findSuppliersHasRequestsByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Return all SuppliersHasRequests entity
	 * 
	 */
	@Test
	public void findAllSuppliersHasRequestss() {
		// TODO: JUnit - Populate test inputs for operation: findAllSuppliersHasRequestss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<SuppliersHasRequests> response = null;
		response = service.findAllSuppliersHasRequestss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllSuppliersHasRequestss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Suppliers entity
	 * 
	 */
	@Test
	public void deleteSuppliersHasRequestsSuppliers() {
		// TODO: JUnit - Populate test inputs for operation: deleteSuppliersHasRequestsSuppliers 
		Integer suppliershasrequests_suppliersIdsuppliers = 0;
		Integer suppliershasrequests_requestsIdrequests = 0;
		Integer related_suppliers_idsuppliers = 0;
		SuppliersHasRequests response = null;
		response = service.deleteSuppliersHasRequestsSuppliers(suppliershasrequests_suppliersIdsuppliers, suppliershasrequests_requestsIdrequests, related_suppliers_idsuppliers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteSuppliersHasRequestsSuppliers
	}

	/**
	 * Operation Unit Test
	 * Return a count of all SuppliersHasRequests entity
	 * 
	 */
	@Test
	public void countSuppliersHasRequestss() {
		Integer response = null;
		response = service.countSuppliersHasRequestss();
		// TODO: JUnit - Add assertions to test outputs of operation: countSuppliersHasRequestss
	}

	/**
	 * Operation Unit Test
	 * Save an existing SuppliersHasRequests entity
	 * 
	 */
	@Test
	public void saveSuppliersHasRequests() {
		// TODO: JUnit - Populate test inputs for operation: saveSuppliersHasRequests 
		SuppliersHasRequests suppliershasrequests_1 = new it.stasbranger.myproject.domain.SuppliersHasRequests();
		service.saveSuppliersHasRequests(suppliershasrequests_1);
	}

	/**
	 * Operation Unit Test
	 * Load an existing SuppliersHasRequests entity
	 * 
	 */
	@Test
	public void loadSuppliersHasRequestss() {
		Set<SuppliersHasRequests> response = null;
		response = service.loadSuppliersHasRequestss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadSuppliersHasRequestss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Requests entity
	 * 
	 */
	@Test
	public void deleteSuppliersHasRequestsRequests() {
		// TODO: JUnit - Populate test inputs for operation: deleteSuppliersHasRequestsRequests 
		Integer suppliershasrequests_suppliersIdsuppliers_1 = 0;
		Integer suppliershasrequests_requestsIdrequests_1 = 0;
		Integer related_requests_idrequests = 0;
		SuppliersHasRequests response = null;
		response = service.deleteSuppliersHasRequestsRequests(suppliershasrequests_suppliersIdsuppliers_1, suppliershasrequests_requestsIdrequests_1, related_requests_idrequests);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteSuppliersHasRequestsRequests
	}

	/**
	 * Operation Unit Test
	 * Save an existing Requests entity
	 * 
	 */
	@Test
	public void saveSuppliersHasRequestsRequests() {
		// TODO: JUnit - Populate test inputs for operation: saveSuppliersHasRequestsRequests 
		Integer suppliersIdsuppliers_2 = 0;
		Integer requestsIdrequests_2 = 0;
		Requests related_requests = new it.stasbranger.myproject.domain.Requests();
		SuppliersHasRequests response = null;
		response = service.saveSuppliersHasRequestsRequests(suppliersIdsuppliers_2, requestsIdrequests_2, related_requests);
		// TODO: JUnit - Add assertions to test outputs of operation: saveSuppliersHasRequestsRequests
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
